<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/register.css" />
		<link rel="stylesheet" type="text/css" href="css/app.css" />
		<link href="css/mui.picker.css" rel="stylesheet" />
		<link href="css/mui.poppicker.css" rel="stylesheet" />
		<style type="text/css">
			.mui-btn {
				font-size: 16px;
				padding: 8px;
				margin: 3px;
			}
			
			h5.mui-content-padded {
				margin-left: 3px;
				margin-top: 20px !important;
			}
			
			h5.mui-content-padded:first-child {
				margin-top: 12px !important;
			}
			
			.ui-alert {
				text-align: center;
				padding: 20px 10px;
				font-size: 16px;
			}
			
			.box {
				display: flex;
				flex-flow: column;
				border-bottom: 1px solid #929292;
			}
			
			.box p {
				padding-top: 10px;
			}
			
			.box select,
			.box input {
				/*width: 50%;*/
				font-size: 12px;
				margin-bottom: 0px;
				text-align: left;
				border-bottom: none;
			}
		</style>
	</head>

	<body>

		<div class="mui-content" id="app">
			<div class="header">
				<h1><span class="num"></span><span>基本信息</span></h1>
				<span class="small_title">企业修改审核日3-5天，以下内容全部为必填项</span>
			</div>
			<div class="input" id="regform">
				<div class="box">
					<p>单位名称</p>
					<input type="text" name="comName" id="comName" placeholder="单位名称" />
				</div>
				<div class="box">
					<p>手机号</p>
					<input type="number" name="comPhone" id="comPhone" placeholder="手机号" />
				</div>
				<div class="box">
					<p>请选择单位分类</p>
					<select name="typeId" id="typeId" class="mui-btn mui-btn-block">
						<option value="4028b88167abe7520167abebc0bb0001">公园</option>
						<option value="4028b88167abe7520167abebe6740002">游泳馆</option>
						<option value="4028b88167abe7520167abec0fdd0003">宾馆</option>
						<option value="4028b88167abe7520167abec873b0004">体育馆</option>
						<option value="4028b88167abe7520167abeca08a0005">博物馆</option>
						<option value="4028b88167abe7520167abecb9e20006">理发店</option>
						<option value="4028b88167abe7520167abecedfb0007">美容院</option>
						<option value="4028b88167abe7520167abed012d0008">图书馆</option>
						<!--<option v-for="val of list" :key="val.typeId" :value="val.typeId">{{val.dicName}}</option>-->
					</select>
				</div>
				<div class="box">
					<input type="text" readonly placeholder="是否拥有许可证" />
					<select class="mui-btn mui-btn-block" id="hasPermit" name="hasPermit">
						<option value="0">有</option>
						<option value="1">无</option>
					</select>
				</div>
				<div class="box">
					<p>许可证号码</p>
					<input type="text" name="permitNumber" id="permitNumber" placeholder="许可证号码" />
				</div>
				<div class="box">
					<p>许可证起始日期</p>
					<input type="date" name="permitStart" id="permitStart" placeholder="许可证起始日期" />
				</div>
				<div class="box">
					<p>许可证结束日期</p>
					<input type="date" name="permitEnd" id="permitEnd" placeholder="许可证结束日期" />
				</div>
				<div class="box">
					<input type="text" readonly placeholder="是否个体工商户" />
					<select name="isPersonal" id="isPersonal" class="mui-btn mui-btn-block">
						<option value="0">是</option>
						<option value="1">否</option>
					</select>
				</div>
				<div class="box">
					<p>行政区划</p>
					<input type="hidden" name="locationArea" id="locationArea" placeholder="行政区划(以空格分隔的字符串)" />
					<button id='showCityPicker3' class="mui-btn mui-btn-block" type='button'>行政区划</button>
				</div>
				<div class="box">
					<p>公司注册地址</p>
					<input type="text" onblur="mui('#comAddress')[0].value = this.value" name="registerAddress" id="registerAddress" placeholder="公司注册地址" />
				</div>
				<div class="box">
					<p>公司经营地址</p>
					<input type="text" name="comAddress" id="comAddress" placeholder="公司经营地址" />
				</div>
				<div class="box">
					<p>邮编</p>
					<input type="text" name="postCode" id="postCode" placeholder="邮编" />
				</div>
				<div class="box">
					<p>法人姓名</p>
					<input type="text" name="comPerson" id="comPerson" placeholder="法人姓名" />
				</div>
				<div class="box">
					<input type="text" readonly placeholder="证件类型" />
					<select class="mui-btn mui-btn-block" name="cardType" id="cardType">
						<option value="1">居民身份证</option>
						<option value="2">护照</option>
						<option value="3">港澳台居民通</option>
						<option value="4">回乡证</option>
						<option value="5">军官证</option>
					</select>
				</div>
				<div class="box">
					<p>证件号</p>
					<input type="text" name="comIdcard" id="comIdcard" placeholder="证件号" />
				</div>
				<div class="box">
					<p>年龄</p>
					<input type="number" name="age" id="age" placeholder="年龄" />
				</div>
				<div class="box">
					<p>联系电话</p>
					<input type="text" name="comTelphone" id="comTelphone" placeholder="联系电话" />
				</div>
				<div class="box">
					<input type="text" readonly placeholder="性别" />
					<select class="mui-btn mui-btn-block" name="sex" id="sex">
						<option value="0">男</option>
						<option value="1">女</option>
					</select>
				</div>
				<div class="box">
					<p>民族</p>
					<input type="text" name="nation" id="nation" placeholder="民族" />
				</div>
				<div class="box">
					<p>职务</p>
					<input type="text" name="duties" id="duties" placeholder="职务" />
				</div>
				<div class="box">
					<p>email</p>
					<input type="email" name="email" id="email" placeholder="email" />
				</div>
				<div class="box">
					<p>法人联系地址</p>
					<input type="text" name="comContact" id="comContact" placeholder="法人联系地址" />
				</div>
				<div class="box">
					<p>统一社会代码</p>
					<input type="text" name="comCreditcode" id="comCreditcode" placeholder="统一社会代码" />
				</div>
				<div class="box">
					<p>组织机构代码</p>
					<input type="text" name="organizationCode" id="organizationCode" placeholder="组织机构代码" />
				</div>
				<div class="box">
					<p>经济类型代码</p>
					<input type="text" name="economicTypeCode" id="economicTypeCode" placeholder="经济类型代码" />
				</div>
			</div>

			<div class="footer">
				<button type="button" class="mui-btn mui-btn-blue mui-btn-block btn_open">提交修改</button>
			</div>
		</div>
	</body>

</html>

<script src="js/mui.min.js"></script>
<script src="js/vue.js"></script>
<script src="js/mui.picker.js"></script>
<script src="js/mui.poppicker.js"></script>
<script src="js/guangxi.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdn.bootcss.com/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.json-2.4.min.js"></script>
<script type="text/javascript">
	mui.init();
	var app = new Vue({
		el: "#app",
		data: {
			list: [],
			typeId: '',
		}
	})
	mui("body").on('tap', '.btn_open', function() {
		if(this.innerText === '提交修改') {
			var iskong = true;
			for(var i = 0; i < mui('#regform>input').length; i++) {
				if(!mui("#regform>input")[i].value) {
					iskong = false;
					console.log(mui('#regform>input')[i].id)
				}
			}
			if(!iskong) {
				mui.toast('请补全信息');
			} else {
				var data2 = getFormData("regform").substring(1, getFormData("regform").length - 1);
				console.log(JSON.stringify(data2));
				mui.ajax(URL + 'meCompanyUser!updateCompanyUser', {
					data: {
						data: data2,
					},
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						console.log(JSON.stringify(data))
						if(data.success) {
							mui.toast(data.msg);
							mui.back();
						}
					},
					error: function(xhr, type, errorThrown) {
						console.log(type)

					}
				});
			}
		} else if(this.innerText === '暂不申请直接登录') {
			gbtiao('qiyedenglu');
		}
	})

	//获取 商户详情
	mui.ajax(URL + 'meCompanyUser!findBeanById', {
		data: {
			id: JSON.parse(TOKEN()).id,
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'get', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		success: function(data) {
			console.log(JSON.stringify(data));

			var arrays = data.clazz;
			try {
				jQuery("#regform").find("input,select,textarea").each(function() {
					if(this.name != "" && this.type != "button") {
						if(this.id in arrays) {
							if(arrays[this.id] != "" && arrays[this.id] != null) {
								this.value = arrays[this.id];
								if(this.id === "permitStart" || this.id === "permitEnd") {
									var riqi = arrays[this.id].split("T")[0];
									this.value = riqi;
								} else if(this.id === "locationArea") {
									mui("#showCityPicker3")[0].innerText = arrays[this.id];
								}
							}
						}
					}
				});
			} catch(e) {
				//TODO handle the exception

				setTimeout(function() {
					alert("您的审核还未通过，还不能进行相关操作！","南宁卫生监督公示系统", "")
					mui.back();
				}, 700)
			}

		},
		error: function(xhr, type, errorThrown) {
			console.log(type);
		}
	});
	//多级联动
	(function($, doc) {
		$.init();
		$.ready(function() {
			/**
			 * 获取对象属性的值
			 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
			 * @param {Object} obj 对象
			 * @param {String} param 属性名
			 */
			var _getParam = function(obj, param) {
				return obj[param] || '';
			};
			//					//级联示例
			var cityPicker3 = new $.PopPicker({
				layer: 2
			});
			cityPicker3.setData(guangxi);
			var showCityPickerButton = doc.getElementById('showCityPicker3');
			var cityResult3 = doc.getElementById('cityResult3');
			showCityPickerButton.addEventListener('tap', function(event) {
				cityPicker3.show(function(items) {
					mui("#locationArea")[0].value = _getParam(items[0], 'text') + " " + _getParam(items[1], 'text') + " " + _getParam(items[2], 'text');
					mui("#showCityPicker3")[0].innerText = _getParam(items[0], 'text') + " " + _getParam(items[1], 'text') + " " + _getParam(items[2], 'text');
					//返回 false 可以阻止选择框的关闭
					//return false;
				});
			}, false);
		});
	})(mui, document);

	function getFormData(formId) {
		var args = {};
		jQuery("#" + formId).find("input,select,textarea").each(function() {
			if(this.name != "" && this.type != "button") {
				if(jQuery(this).val() != "") {
					args[this.name] = jQuery.trim(jQuery(this).val());
				}
			}
		});
		var arr = new Array();
		arr.push(args);
		return jQuery.toJSON(arr);
	}
</script>